{% extends "template/listEdit.volt" %}

{% block title %}aopa管理{% endblock %}


{% block filter %}
<form name="upload" enctype="multipart/form-data" method="post" id="upload">
    <div class="col-md-4 col-sm-6 col-xs-12">
        <table>
            <tr>
                <th>用户文件:</th>
                <td><input type="file" id="aopa" name="aopa"></td>
                <input type="hidden" id="id" name="id" value="0">
            </tr>
            <tr>
                <td colspan="2">
                    <div id="btn_reset_param" class="btn-0 button" onClick="actionAdd()">添加</div>
                    <div id="btn_search_data" class="btn-1 button" onClick="actionDelete()">删除</div>
                </td>
            </tr>
        </table>
    </div>
</form>
{% endblock %}

{% block hiddenOperation %}hidden{% endblock %}

{% block jscontent %}
    <script>

        function actionAdd() {
        	var form = document.getElementById('upload'), 
            formData = new FormData(form); 
			$.ajax({ 
				url:"/user/addAOPA", 
				type:"post", 
				data:formData, 
				processData:false, 
				contentType:false, 
				success:function(res){ 
					if(res){ 
						if(res.data.error.length>1)
							FAlert("添加成功<br>" + res.data.error+"不存在", function (result) {

		                    }) 
						else
							FAlert("添加成功", function (result) {

		                    })
					  	$('#id').val(res.data.success);
						PageDataProxy.refresh(); 
				 } 
				}, 
				error:function(err){ 
				 alert("添加失败",err); 
				}
			}) 
        }
        
        function actionDelete(tag) {
            var form = document.getElementById('upload'), 
            formData = new FormData(form); 
			$.ajax({ 
				url:"/user/deleteAopa", 
				type:"post", 
				data:formData, 
				processData:false, 
				contentType:false, 
				success:function(res){ 
				 if(res){ 
					if(res.data.error.length>1)
						FAlert("删除成功<br>" + res.data.error+"不存在", function (result) {

	                    })
					else
						FAlert("删除成功", function (result) {

	                    }) 
				  	$('#id').val(res.data.success);
					PageDataProxy.refresh(); 
				 }
				}, 
				error:function(err){ 
				 alert("添加失败",err); 
				}
			}) 
        }        

        $(function () {
            PageDataProxy.init({
                "url": "/user/aopa",
                "table_id": "#mytable",
                "page_control_id": "#data-wrap",
                "page_size_id": "#rows-perpage-select",
                "page_total_id": "#data_count_total",
                "use_check_box": false,
                "data_field_process": function (name, value) {
                    return value;
                },
                "table_style": {
                    "nickname": "width-150",
                    "phone": "width-450",
                    "created_at": "width-450",
                    "online": "width-m",
                    "aopa": "width-m"
                },

            });

            PageDataProxy.refresh();
        })
    </script>
{% endblock %}